package com.molichuxing.baselibrary.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.molichuxing.baselibrary.R;

public class HeadPortraitDialog extends BaseDialog implements View.OnClickListener {

	private OnPortraitClickListener portraitClick;
	private View mView = null;

	public HeadPortraitDialog(Context context, int theme) {
		super(context, android.R.style.Theme_Light_NoTitleBar, false);
		portraitClick = (OnPortraitClickListener) context;
	}

	/**
	 * 重写这个方法添加自定义view
	 *
	 * @return view
	 */
	@Override
	protected View customPanel() {
		LayoutInflater inflater = LayoutInflater.from(mContext);
		
		LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.pop_change_head_portrait, null);

		LinearLayout pop_ll_camera = linearLayout.findViewById(R.id.pop_ll_camera);
		pop_ll_camera.setOnClickListener(this);
		LinearLayout pop_ll_phone_album = linearLayout.findViewById(R.id.pop_ll_phone_album);
		pop_ll_phone_album.setOnClickListener(this);
		LinearLayout pop_ll_cancel = linearLayout.findViewById(R.id.pop_ll_cancel);
		pop_ll_cancel.setOnClickListener(this);

		return linearLayout;
	}

	/**
	 * Called when a view has been clicked.
	 * @param v
	 * The view that was clicked.
	 */
	@Override
	public void onClick(View v) {
		dismiss();
		mView = v;
	}

	/**
	 * dismiss回调
	 */
	/*@Override
	protected void onDismissed() {
		super.onDismissed();
		if (mView != null) {
			if (R.id.pop_ll_cancel == mView.getId()) {
				
			}else if(R.id.pop_ll_camera == mView.getId()){
				
			}else if(R.id.pop_ll_phone_album == mView.getId()){
				
			}
		}
		mView = null;

	}*/
	
	@Override
	protected void onDismissed() {
		super.onDismissed();

		if (mView != null) {
			portraitClick.OnPortraitClick(mView.getId());
			mView = null;
		}
	}
	
	public interface OnPortraitClickListener {
		public void OnPortraitClick(int id);
	}
}
